<?php

class CarregaRegistrador{
	
	var $db;
	var $db2;
	var $tpl;
	
	
	function CarregaRegistrador($tmp_path,$js_path) {
		$this->db = new Persist();
		$this->db2 = new Persist();
		$this->tpl = new TemplatePower(@$tmp_path.'tmpl.CarregaRegistrador.html');
		
		$this->tpl->prepare();
		$this->tpl->assign('path',@$js_path.'libs.CarregaRegistrador.js');
	}
	
	function revistaCampo($campo,$valor){
		$this->db->sql = "SELECT $campo FROM cadastro WHERE $campo = '$valor' ";
		
		if($this->db->ler("Sim") > 0 ){
			return "1";
		}
		return "0";
	}
	
	function registraUsuario($array = NULL){
			$sql = " INSERT INTO cadastro ( ";
			foreach ($array as $name => $value) {
						$sql .= "$name,";
    		}
			
			$sql .= " pessoa) 
					VALUES (";
			
			foreach ($array as $name => $value) {
						$sql .= "'$value',";
    		}				
			$sql .= " 1)";
			
			$this->db->sql = $sql;
			$this->db->ins();
	}
	
	function escreveHtml(){
		return $this->tpl->getOutputContent();
	}
}
?>